# -*- coding: utf-8 -*-
"""
 @Time    : 2021/1/27 下午2:21
 @Author  : tgy
 
"""


class Person:
    __slots__ = ['names']

    def __init__(self):
        self.names = []

    def add_name(self, name):
        self.names.append(name)

    def __iter__(self):
        # for name in self.names:
        #     yield name
        return iter(self.names)

    def __reversed__(self):

        for i in range(len(self.names) -1,-1,-1):
            yield self.names[i]


def test01():
    ...
    person = Person()
    person.add_name('zhangsan')
    person.add_name('lisi')
    for name in person:
        print(name)

    for name in reversed(person):
        print(name)

if __name__ == '__main__':
    ...
    test01()